package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-10
 * Time: 15:04
 */



class Animal{
    public String name;

    public Animal(String name) {
        this.name = name;
    }
}

interface IFlying{

    void fly();
}

interface IRunning extends IFlying{
    //类IRunning拓展了IFlying的功能
    void run();
    //接口与接口之间继承后IRunning拓展了IFlying功能
    //有了IRunning的功能的类也要重写IFlying这个方法
}

interface ISwimming{
    void swim();
}

interface IClimbing{
    void climb();
}
//创建一个Ant类
//利用implements关键字来实现接口
//一个类可以实现多个接口，接口之间利用逗号
//实现了接口必须要在接口中重写接口中的方法
//重写方法快捷键：鼠标移动到implements关键字上然后 alt+enter
class Ant implements IClimbing,IRunning{
    public String name;
    @Override
    public void run() {
        System.out.println(this.name+"要跑步");
    }

    @Override
    public void climb() {
        System.out.println(this.name+"爬山");
    }


    @Override
    public void fly() {

    }
}
class Monkey extends Animal implements IClimbing,IRunning{

    public Monkey(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+"要跑步");
    }


    @Override
    public void climb() {
        System.out.println(this.name+"爬树");
    }

    @Override
    public void fly() {

    }
}


public class Test1 {

    public static void main(String[] args) {

    }
}
